<?php
include_once( 'init.php' );
$statePostId = $_GET["post"];
$since_id = (int)$_GET['since'] ? (int)$_GET['since'] : 0;
$max_id = (int)$_GET['max'] ? (int)$_GET['max'] : 0;
$page = (int)$_GET['page'] ? (int)$_GET['page'] : 1;
$count = (int)$_GET['count'] ? (int)$_GET['count'] : 20;
$statePostCommentList = $c->get_comments_by_sid($statePostId, $page, $count, $since_id, $max_id);
for($i=0; $i<count($statePostCommentList["comments"]); $i++){
	$statePostComment = $statePostCommentList["comments"][$i];
	$statePostCommentText = format($statePostComment["text"]);
	$statePostCommentUserName = $statePostComment["user"]["screen_name"];
	$statePostCommentUserId = $statePostComment["user"]["id"];
	$statePostCommentUserName = $statePostCommentUserName?$statePostCommentUserName:$statePostCommentUserId;
	if($i==0 && !$_GET["request"]){
?>
<script type="text/javascript">
var max_id = "<?php echo $statePostComment["id"]; ?>";
</script>
<?php
	}
?>
<div class="statePostComment" id="comment_<?php echo $statePostComment["id"]; ?>">
<div>
<div class="statePostCommentHead"><img style="width: 30px; height: 30px;" src="<?php echo $_SERVER['HTTPS']?"/qsimg/".base64_encode($statePostComment["user"]["profile_image_url"]):$statePostComment["user"]["profile_image_url"]; ?>" /></div>
<div class="statePostCommentPost">
<div><span class="statePostCommentUserName"><a href="/user/<?php echo $statePostCommentUserName; ?>"><?php echo $statePostCommentUserName; ?></a></span> - <?php echo $statePostCommentText; ?></div>
<div class="statePostCommentTime"><?php echo formatTime($statePostComment["created_at"]); ?> - <span class="commentsReplayAction"><a href="##" onclick="setElCenter(document.getElementById('replaybox-<?php echo $statePostId; ?>'));replayComment('replaybox-<?php echo $statePostId; ?>','<?php echo $statePostCommentUserName; ?>','commentid-<?php echo $statePostId; ?>','<?php echo $statePostComment["id"]; ?>');document.getElementById('commentbox-<?php echo $statePostId; ?>').focus();return false;">回复</a><?php if($statePostUserUid == $uid || $statePostComment["user"]["id"]==$uid){ ?> - <a href="##" onclick="delComment(<?php echo $statePostComment["id"]; ?>);return false;">删除</a><?php }; ?></span></div>
</div>
<div class="floatClear"></div>
</div>
</div>
<?php
}
?>